package brwarner.game.ui 
{
	import brwarner.game.God;
	import flash.display.Sprite;
	import flash.events.Event;
	import brwarner.game.GameConstants;
	
	/**
	 * ...
	 * @author Brook Jensen
	 */
	public class ManaPanel extends Sprite 
	{
		//God that we are tracking
		var _god:God;
		
		//Mana bars
		var _water:Bar, _fire:Bar, _air:Bar, _ground:Bar;
		
		public function ManaPanel(g:God) 
		{
			//Set god
			_god = g;
			_god.addEventListener( "onManaChanged", function( e:Event ) { refresh(); } );
			
			//Setup bars
			_fire = new Bar( "Fire", 100, GameConstants.MAX_MANA[0], 0xFF0000 );
			_water = new Bar( "Water", 100, GameConstants.MAX_MANA[1], 0x0000FF );
			_air = new Bar( "Air", 100, GameConstants.MAX_MANA[2], 0xC0C0C0 );
			_ground = new Bar( "Ground", 100, GameConstants.MAX_MANA[3], 0x660000 );
			
			_fire.y = 0;
			_water.y = _fire.height + 5;
			_air.y = _fire.height + _water.height + 10;
			_ground.y = _fire.height + _water.height + _air.height + 15;
			
			//Add children
			addChild( _fire );
			addChild( _water );
			addChild( _air );
			addChild( _ground );
			
			refresh();
			redraw();
		}
		
		public function redraw( ):void
		{
			graphics.clear();
			graphics.beginFill( 0xFFFFFF );
			graphics.lineStyle( 1, 0 );
			graphics.drawRect( 0, 0, 200, 100 );
			graphics.endFill();
		}
		
		public function refresh( ):void
		{
			//Refresh values
			_fire.value = _god.Fire;
			_water.value = _god.Water;
			_ground.value = _god.Ground;
			_air.value = _god.Air;
		}
		
	}

}